﻿Module MainModule


    ' variables publiques pour la gestion du GPS
    Public m_isFormGPSOpen As Boolean = False
    Public m_strGpsDeviceIsOpen As Boolean = False
    Public m_isGpsInterpreteurOpen As Boolean = False
    Public oProtocole As ClsProtocole


    Public Sub Main()
        Try
            REM Création de la fenêtre principale et affichage
            'Dim wFormMain As New FormMain
            'wFormMain.Show()
            Application.DoEvents()

            REM Creéation du splash screen et affichage
            Dim wSplash As New FormSplash
            wSplash.Show()

            REM On attend 5 secondes avant de continuer
            Dim wStart As TimeSpan = Now.TimeOfDay
            Do While Now.TimeOfDay.Subtract(wStart).Seconds < 3
                Application.DoEvents()
            Loop

            REM On ferme le splash screen
            FormSplash.Hide()
            FormSplash.Close()
            'FormMain.Show()
            REM On lance la fenêtre principale de l'application
            Application.Run(FormMain)

        Catch ex As Exception
            'En cas d'erreur
            '*******************************************
            'sauvegarde du track
            Try
                SaveTrack(FormMain.NSDossier & "TrackGPS_" & Now.ToString("yyMMdd") & ".gpx", FormMain.NSDossier)
            Catch exIn As Exception
                MsgBox(exIn.Message, MsgBoxStyle.Exclamation, "Pocket eRelevé")
            End Try

            '******************************************************
            'sauvegarde des données saisies s'il y en a !
            Try
                SaveObservation(FormMain.NSDossier, FormMain.oListObs)
            Catch exIn As Exception
                MsgBox(exIn.Message, MsgBoxStyle.Exclamation, "Pocket eRelevé")
            End Try

            MsgBox("Erreur fatale : " & ex.Message, MsgBoxStyle.Critical, "Pocket eReleve")
        End Try
        Cursor.Current = Cursors.Default
    End Sub

End Module
